Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};
Array.method('reduce', function (f, value) {
    for (let i = 0; i < this.length; i++) {
        value = f(this[i], value);
    }
    return value;
});
let values = [1,2,3,4,5];
console.log(values.reduce(function (a, b) {
    return a + b;
}, 0));

// let sum = values.reduce(function(prev, cur, index, array){
//     return prev + cur;
// });
